<?php
$id = $_REQUEST['cid'];
$car = CarDao::find($id);
$car = CarDao::findCarOptions($car);
$arrOptions = CarDao::findAllOptions();
$arrCarOptions = $car->getOptions();
foreach ($arrOptions as $option) {
	if (in_array($option['id'], $arrCarOptions)) {
   	$optionNames[]=  $option['name'];
	}
}
if (Security::isCurrentUserGrantedWith("ROLE_ADMIN")) {
?>
	<span class="hiddenp">
  	<a href="../<?php echo $www;?>/index_admin.php?entity=car&amp;action=update&amp;id=<?php print $car->id?>">Edit</a>
  	</span>
<?php	
}
?>

<table class="table">
		
	<tr>
		<td class="valuebold"><?php echo $car->vehicle;?></td>
	</tr>
	<tr>
		<td class="labeldetails">Vehicle Photos</td>
	</tr>	
	<tr>
		<td class="labeldetails">
			 <a href="popup.php?carId=<?php echo $car->id?>" onclick="MM_openBrWindow('popup.php?carId=<?php echo $car->id?>','','width=780,height=600');return false"> 
			 <?php 
			 if ($car->photo != "") {
			 ?>
			 <img width="100px" height="100px" alt="" src="img/cars/_thb_<?php echo $car->photo?>"/>
			 <?php
			 }
			 ?>
			 <?php 
			 if ($car->pic1 != "") {
			 ?>
			 <img width="100px" height="100px" alt="" src="img/cars/_thb_<?php echo $car->pic1?>"/>
			 <?php
			 }
			 ?>
			 <?php 
			 if ($car->pic2 != "") {
			 ?>
			 <img width="100px" height="100px" alt="" src="img/cars/_thb_<?php echo $car->pic2?>"/>
			 <?php
			 }
			 ?>
			 <?php 
			 if ($car->pic3 != "") {
			 ?>
			 <img width="100px" height="100px" alt="" src="img/cars/_thb_<?php echo $car->pic3?>"/>
			 <?php
			 }
			 ?>
			 <?php 
			 if ($car->pic4 != "") {
			 ?>
			 <img width="100px" height="100px" alt="" src="img/cars/_thb_<?php echo $car->pic4?>"/>
			 <?php
			 }
			 ?>
			 </a>
		</td>
	</tr>
	<tr>
		<td>
		<table class="table">  
		<tr >
			<td colspan="2" class="valuebold">Dealership Information</td>
			<td class="valuebold">Retail Price</td>
		</tr>
		<tr>
			<td>Dealership</td>
			<td>MR Motors</td>
			<td><?php echo $car->price;?></td>
		</tr>
		<tr>
			<td>Location</td>
			<td>Coffs Harbour</td>
			<td>&nbsp;</td>
		</tr>
		</table>	
		</td>
	</tr>
	<tr>
		<td>
		<table class="table">
		<tr >
			<td colspan="2" class="valuebold">Vehicle Information</td>
		</tr>
		<tr>
			<td>Vehicle</td>
			<td><?php echo $car->vehicle;?></td>
		</tr>		
		<tr>
			<td>Body Colour</td>
			<td><?php echo $car->color;?></td>
		</tr>
		<tr>
			<td>Doors</td>
			<td><?php echo $car->door;?></td>
		</tr>
		<tr>
			<td>Cylinders</td>
			<td><?php echo $car->cylind;?></td>
		</tr>
		<tr>
			<td>Fuel Type</td>
			<td><?php echo $car->fuel;?></td>
		</tr>
		<tr>
			<td>Gears</td>
			<td><?php echo $car->gear;?></td>
		</tr>
		<tr>
			<td>Gearbox</td>
			<td><?php echo $car->gearbox;?></td>
		</tr>
		<tr>
			<td>Odometer</td>
			<td><?php echo $car->odometer;?></td>
		</tr>
		<tr>
			<td>Rego</td>
			<td><?php echo $car->rego;?></td>
		</tr>
		<tr>
			<td>StockNo</td>
			<td><?php echo $car->stock;?></td>
		</tr>
		<tr>
			<td>Last-Updated</td>
			<td><?php echo $car->utime;?></td>
		</tr>
		<tr>
			<td>VIN</td>
			<td><?php echo $car->vin?></td>
		</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td colspan="2" class="valuebold">Dealer Comments</td>
	</tr>	
	<tr>
		<td><?php echo $car->comments;?></td>
	</tr>
	<tr>
	<td>
	<table class="table">
		<tr>
			<td colspan="2" class="valuebold">Vehicle Options</td>
		</tr>
		<tr>
		<td>
			<table cellpadding="0" cellspacing="0" width="740px;" border="0px;">
			<?php 
			for ($i=0; $i<count($optionNames); $i+=3) {
			?>
			<tr>
			    <td><?php echo $optionNames[$i]?></td>
			    <td><?php echo $optionNames[$i+1]?></td>
			    <td><?php echo $optionNames[$i+2]?></td>
			</tr>
			<?php	
			}
			?>
			</table>
		</td>	
		</tr>
	</table>
	</td>	
	</tr>
	<tr>
		<td>
      	<button class="hiddenp" onclick="javascript:print()" >Print</button>
      	<button class="hiddenp" onclick="MM_openBrWindow('popup.php?carId=<?php echo $car->id?>','','width=780,height=600');return false">Enquiry</button>
		</td>
	</tr>	
</table>
